#ifndef RAYTRACER_H_
#define RAYTRACER_H_

#include "Triangle.h"
#include "AABB.h"
#include "KdNode.h"
#include "Ray.h"
#include "ShadowRay.h"
#include <vector>

using std::vector;


/**
 * triangles.size() > 0
 * aabb stores the size of the root-aabb
 */
#ifdef USERECURSIVEBUILD
KdNode* recBuildKdTree(const vector<Triangle*>& triangles, const AABB& aabb);
#else
KdNode* itBuildKdTree(const vector<Triangle*>& triangles, const AABB& aabb);
#endif

void printKdTree(const KdNode* n);

void drawKdTree(const KdNode* n, int omitAxis, int x, int y, const AABB& aabb);

#ifdef USERECURSIVETRAVERSAL
float recTraverse(KdNode* root, Ray& ray, const AABB& aabb);

bool recTraverseShadow(KdNode* root, ShadowRay& shadowRay, const AABB& aabb);

#else
float itTraverse(KdNode* root, Ray& ray, const AABB& aabb);

bool itTraverseShadow(KdNode* root, ShadowRay& shadowRay, const AABB& aabb);
#endif

#endif
